/*
 *  Copyright 2012 yura.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package org.opu.db.obj.vis.domain.wrappers;

import java.util.List;
import com.google.common.collect.Lists;
import org.opu.db.obj.vis.domain.domains.AbstractAttributeEntry;
import org.opu.db.obj.vis.domain.domains.AttributeId;

/**
 *
 * @author yura
 */
public class AttributeWrapper extends AbstractWrapper<AbstractAttributeEntry> {

    private AbstractAttributeEntry refferencedTo;
    private List<AbstractAttributeEntry> refferencesOnIt = Lists.newArrayList();

    public AttributeWrapper(AbstractAttributeEntry column,
            AbstractAttributeEntry refferencedTo,
            List<AbstractAttributeEntry> refferencesOnIt) {
        super(column);
        this.refferencedTo = refferencedTo;
        this.refferencesOnIt = refferencesOnIt;
    }

    public AttributeWrapper(AbstractAttributeEntry column,
            AbstractAttributeEntry refferencedTo) {
        this(column, refferencedTo, Lists.<AbstractAttributeEntry>newArrayList());
    }

    public AttributeWrapper(AbstractAttributeEntry column) {
        this(column, null);
    }

    public AbstractAttributeEntry getAttributeEntry() {
        return getWrapped();
    }

    public AbstractAttributeEntry getRefferencedTo() {
        return refferencedTo;
    }

    public void setRefferencedTo(AbstractAttributeEntry refferencedTo) {
        this.refferencedTo = refferencedTo;
    }

    public List<AbstractAttributeEntry> getRefferencesOnIt() {
        return refferencesOnIt;
    }

    @Override
    public String toString() {
        AbstractAttributeEntry column = getAttributeEntry();
        if (column == null) {
            return "[attributeEntry is NULL]";
        }
        
        AttributeId id = column.getId();
        if (column == null) {
            return "[attributeId is NULL]";
        }

        return id.getName();
    }
}
